package org.gaia.j3d.ui.views;


import java.awt.Frame;
import java.io.FileNotFoundException;

import javax.media.j3d.BranchGroup;

import org.eclipse.swt.SWT;
import org.eclipse.swt.awt.SWT_AWT;
import org.eclipse.swt.widgets.Composite;


import com.sun.j3d.loaders.Scene;
import com.sun.j3d.utils.geometry.ColorCube;

public class SWTJava3D extends Composite
{

	Scene3D scene3d;
	Content3D content;
	BranchGroup branch = null;
	BranchGroup bg = new BranchGroup();
	
	public BranchGroup getRoot(){
		return scene3d.bgScene;
		//root.addChild(new ColorCube(1));
		//System.out.println(root.toString());
	}
	// setup canvas and universe
	public SWTJava3D(Composite parent, int style)
	{
		// set SWT.EMBEDDED so we can use SWT_AWT.new_Frame
		super(parent, SWT.EMBEDDED | style);

		// setup canvas
		scene3d = new Scene3D();
		// create AWT wrapper
		
		
		
		Frame frame = SWT_AWT.new_Frame(this);
		frame.add(scene3d.canvas);
		
		//content = new Content3D();
		//scene3d.bgScene.addChild(content);
		//content.addVRML();
		
		bg = new BranchGroup();
		bg.setCapability(BranchGroup.ALLOW_DETACH);
		bg.setCapability(BranchGroup.ALLOW_CHILDREN_WRITE);
		bg.setCapability(BranchGroup.ALLOW_CHILDREN_EXTEND);
		bg.setCapability(BranchGroup.ALLOW_CHILDREN_READ);
		bg.setCapability(BranchGroup.ALLOW_BOUNDS_READ);
		bg.setCapability(BranchGroup.ALLOW_BOUNDS_WRITE);
		bg.addChild(new ColorCube(1));
		scene3d.bgScene.addChild(bg);
	}
	

	/*public void detach(){
		content.cube.detach();
	}
	
	public void attach(){
		content.addChild(content.cube);
		content.addVRML();
	}*/

}
